/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.flexengine.config;

import java.io.Serializable;

/**
 * @author Luann R. Athayde
 * @version 1.0
 * @since 1.0
 */
public class FlexDisplayMode implements Serializable {
    
    private int width;
    private int height;
    private int bitDepth;
    private int refreshRate;

    public FlexDisplayMode(int width, int height, int bitDepth, int refreshRate) {
        this.width = width;
        this.height = height;
        this.bitDepth = bitDepth;
        this.refreshRate = refreshRate;
    }

    public FlexDisplayMode() {
        this(0,0,0,0);
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getBitDepth() {
        return bitDepth;
    }

    public void setBitDepth(int bithDepth) {
        this.bitDepth = bithDepth;
    }

    public int getRefreshRate() {
        return refreshRate;
    }

    public void setRefreshRate(int refreshRate) {
        this.refreshRate = refreshRate;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 47 * hash + this.width;
        hash = 47 * hash + this.height;
        hash = 47 * hash + this.bitDepth;
        hash = 47 * hash + this.refreshRate;
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FlexDisplayMode other = (FlexDisplayMode) obj;
        if (this.width != other.width) {
            return false;
        }
        if (this.height != other.height) {
            return false;
        }
        if (this.bitDepth != other.bitDepth) {
            return false;
        }
        return this.refreshRate == other.refreshRate;
    }
    
    @Override
    public String toString() {
        return format(width, height, bitDepth, refreshRate);
    }
    
    public static String format(int width, int height, int bitDepth, int refreshRate) {
        String format = width + "x" + height;
        if( bitDepth>0 ) {
            format += "x"+bitDepth;
        }
        format += " "+refreshRate + "Hz";
        return format;
    }
    
}
